Skip to content

Conversation

prwhelan
Copy link
Member

@prwhelan prwhelan commented Sep 25, 2025

An initial IndicesOptions for CrossProject.

This will be used to identify when the index must be resolved for a cross-project search. It currently always defaults to false so we can start reading the value, and a later commit will handle enabling it.


Design decisions:

  1. We are creating a new IndicesOptions group rather than reusing GatekeeperOptions. We want a group for options that are not exposed to the user that also contextually change over the lifetime of the request. The idea behind this option is to resolve the index expression in one spot of the request's lifetime, skip resolution in other parts of the request's lifetime, and potentially take other actions like reject the request for ML.
  2. We are following the verb + object naming format that is consistent with this file, so resolveCrossProject, to match other options like matchClosed and includeFailureIndices.

An initial IndicesOptions for CrossProject.

This will be used to identify when the index must be resolved for a
cross-project search. It currently always defaults to false so we can
start reading the value, and a later commit will handle enabling it.
@prwhelan prwhelan added >non-issue Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch :Search Foundations/Search Catch all for Search Foundations labels Sep 25, 2025
@prwhelan prwhelan marked this pull request as ready for review October 7, 2025 01:28
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@prwhelan prwhelan requested a review from ywangd October 7, 2025 01:31
Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mostly good to me. I have only small comments. It would be good if @jbaiera (respsenting the data-management team who owns IndicesOptions) can take a look as well. Thanks!

|| WildcardOptions.ALLOW_NO_INDICES.equals(name)
|| "allowNoIndices".equals(name);
|| "allowNoIndices".equals(name)
|| ResolutionModeOptions.CROSS_PROJECT_NAME.equals(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably unnecessary. This method is used in a single place for error reporting on RestoreSnapshotRequest which is user facing. We don't expect it to be set on such request and hence no need to check here. I think it's might be the reason why we don't have everything here.

PS: It might be helpful to make each option explicitly declare whether it's internal or not so that their usage is easier to reason with. Not suggesting it for this PR. Just writing it down as an idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could - it exists to prevent xcontent parsing from erroring here: https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java#L582

We'd change it so that we don't write any new xcontent if the field is false, then we check if the field is present before parsing it here: https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java#L1136

Does that sound good? I can push the change as a separate commit so we can see what it looks like and revert it if we don't like it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't want to expose this new option to REST layer at all since it is internally only. For example, the parsing and toXContent methods of GatekeeperOptions do not involve any of the allowXxx options since they are internal, i.e. not configurable by end-users as described in its javadoc. Along this line of reasoning, I think we can just have no-op parsring and toXContent methods here to avoid inadverntly exposing it to end-users. It means RestoreSnapshotRequest will throw an exception if user specifies the new option and that is desirable. Overall I think it is easier to expose it later if necessary while more difficult to hide if already exposed.

PS: There is some fuzziness on how it should work for background tasks such as ML datafeed. I think the previous discussion seems to prefer inject the indicesOption when necessary, similar to how it is injected at the REST layer for ResolveIndexRequest. In another word, we don't plan to rely on parsing it from the job's configs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do need a way to capture it in the job config though, because logs will resolve differently over time. We would likely want it such that each time the ML datafeed (or Transform) runs, it resolves logs based on the current state of the system. The alternative is resolving once when the job is created, logs -> p1:logs, -p2:logs and then a future p3:logs would be omitted from the job.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's easier to add toXContent methods later than it is to remove toXContent methods, so we can start with them being no-op and go from there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we do need a way to capture it in the job config though, because logs will resolve differently over time.

This is the fuziness part for me. An alternative to capturing is to inject it when the job runs similar to how we plan to inject it for RestResolveIndexAction. I am not sure exactly how that would look like yet but feels theorectically possible.

I assume it's easier to add toXContent methods later than it is to remove toXContent methods

Yep exactly my thought as well.

@jbaiera jbaiera self-requested a review October 8, 2025 18:59
Copy link
Member

@jbaiera jbaiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the indices options look fine to me!

WildcardOptions wildcardOptions,
GatekeeperOptions gatekeeperOptions
GatekeeperOptions gatekeeperOptions,
CrossProjectModeOptions crossProjectModeOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add an entry to the java docs above here for this?

Copy link
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for the discussion and iterations!

@prwhelan prwhelan enabled auto-merge (squash) October 10, 2025 12:44
@prwhelan prwhelan merged commit 27f5fac into elastic:main Oct 10, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch v9.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants